*      Here's an example of a COBOL class which inherits from an abstract .NET type.
       
       class-id. ParagraphWriter as "Barbarian.ParagraphWriter" inherits "System.IO.TextWriter".

       environment division.
       configuration section.
       repository.

           class  DocParagraph       as "System.Windows.Documents.Paragraph"
           class  DispatcherPriority as "System.Windows.Threading.DispatcherPriority"
           enum   Encoding           as "System.Text.Encoding"
           class  ArrayOfChar        as "System.Char[]"
           class  ArrayOfObject      as "System.Object[]"
           .

*      The factory object's definition begins here. This particular factory
*      object defines a class-level method.
 
       factory.
       data division.
       procedure division.
       
*      The CreateNew method allocates a new object reference, and invokes
*      initParagraph to initialize the new instance.

       method-id. "CreateNew" internal.
       data division.
       linkage section.
       01  docPar   DocParagraph.
       01  writer   object reference active-class.
       procedure division using docPar returning writer.
           invoke self::"New"() returning writer
           invoke writer::"Initialize"(docPar)
       end method "CreateNew".

       end factory.

*      The definition for instance objects begins here.

       object.
       working-storage section.
       01  _outputParagraph DocParagraph.

       method-id. "Initialize" is private.
       procedure division using outputParagraph as DocParagraph.
           set _outputParagraph to outputParagraph
       end method "Initialize".

       method-id. get property "Encoding" is public override.
       procedure division returning coding as Encoding.
           set coding to Encoding::"UTF8"
       end method.

*--------------------------------------------------------------------------------------------------
       
*Write(Boolean)
       method-id. "Write" is public.
       procedure division using b as type "System.Boolean".
           invoke self::"Write"("Not implemented: Write(Boolean)")
       end method "Write".

*Write(Char)
       method-id. "Write" is public.
       procedure division using c as character.
           invoke self::"Write"(c::"ToString"())
       end method "Write".

*Write(Char[])
       method-id. "Write" is public.
       procedure division using arr as ArrayOfChar.
           invoke self::"Write"("Not implemented: Write(Char[])")
       end method "Write".

*Write(Decimal)
       method-id. "Write" is public.
       procedure division using d as type "System.Decimal".
           invoke self::"Write"("Not implemented: Write(Decimal)")
       end method "Write".

*Write(Double)
       method-id. "Write" is public.
       procedure division using d as type "System.Double".
           invoke self::"Write"("Not implemented: Write(Double)")
       end method "Write".

*Write(Int32)
       method-id. "Write" is public.
       procedure division using i as type "System.Int32".
           invoke self::"Write"("Not implemented: Write(Int32)")
       end method "Write".

*Write(Int64)
       method-id. "Write" is public.
       procedure division using i as type "System.Int64".
           invoke self::"Write"("Not implemented: Write(Int64)")
       end method "Write".

*Write(Object)
       method-id. "Write" is public.
       procedure division using o as type "System.Object".
           invoke self::"Write"("Not implemented: Write(Object)")
       end method "Write".

*Write(Single)
       method-id. "Write" is public.
       procedure division using s as type "System.Single".
           invoke self::"Write"("Not implemented: Write(Single)")
       end method "Write".

*Write(String)
       method-id. "Write" is public.
       data division.
       working-storage section.
       01  docRun            type "System.Windows.Documents.Run".
       procedure division using s as string.
           set docRun to new "System.Windows.Documents.Run"(s)
           invoke _outputParagraph::"Inlines"::"Add"(docRun)
       end method "Write".

*Write(UInt32)
       method-id. "Write" is public.
       procedure division using i as type "System.UInt32".
           invoke self::"Write"("Not implemented: Write(UInt32)")
       end method "Write".

*Write(UInt64)
       method-id. "Write" is public.
       procedure division using i as type "System.UInt64".
           invoke self::"Write"("Not implemented: Write(UInt64)")
       end method "Write".

*Write(String, Object)
       method-id. "Write" is public.
       procedure division using s as type "System.String", o as type "System.Object".
           invoke self::"Write"("Not implemented: Write(String, Object)")
       end method "Write".

*Write(String, Object[])
       method-id. "Write" is public.
       procedure division using s as type "System.String", arr as ArrayOfObject.
           invoke self::"Write"("Not implemented: Write(String, Object[])")
       end method "Write".

*Write(Char[], Int32, Int32)
       method-id. "Write" is public.
       linkage section.
       01  buffer    object reference ArrayOfChar.
       01  intIndex  binary-long.
       01  intCount  binary-long.
       procedure division using buffer, intIndex, intCount.
           invoke self::"Write"(string::"New"(buffer, intIndex, intCount))
       end method "Write".

*Write(String, Object, Object)
       method-id. "Write" is public.
       procedure division using s as type "System.String", o1 as type "System.Object", o2 as type "System.Object".
           invoke self::"Write"("Not implemented: Write(String, Object, Object)")
       end method "Write".

*Write(String, Object, Object, Object)
       method-id. "Write" is public.
       procedure division using s as type "System.String", o1 as type "System.Object", o2 as type "System.Object", o3 as type "System.Object".
           invoke self::"Write"("Not implemented: Write(String, Object, Object, Object)")
       end method "Write".

*--------------------------------------------------------------------------------------------------
       
*WriteLine(Boolean)
       method-id. "WriteLine" is public.
       procedure division using b as type "System.Boolean".
           invoke self::"Write"("Not implemented: WriteLine(Boolean)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Char)
       method-id. "WriteLine" is public.
       procedure division using c as character.
           invoke self::"Write"(c::"ToString"())
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Char[])
       method-id. "WriteLine" is public.
       procedure division using arr as ArrayOfChar.
           invoke self::"Write"("Not implemented: WriteLine(Char[])")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Decimal)
       method-id. "WriteLine" is public.
       procedure division using d as type "System.Decimal".
           invoke self::"Write"("Not implemented: WriteLine(Decimal)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Double)
       method-id. "WriteLine" is public.
       procedure division using d as type "System.Double".
           invoke self::"Write"("Not implemented: WriteLine(Double)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Int32)
       method-id. "WriteLine" is public.
       procedure division using i as type "System.Int32".
           invoke self::"Write"("Not implemented: WriteLine(Int32)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Int64)
       method-id. "WriteLine" is public.
       procedure division using i as type "System.Int64".
           invoke self::"Write"("Not implemented: WriteLine(Int64)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Object)
       method-id. "WriteLine" is public.
       procedure division using o as type "System.Object".
           invoke self::"Write"("Not implemented: WriteLine(Object)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Single)
       method-id. "WriteLine" is public.
       procedure division using s as type "System.Single".
           invoke self::"Write"("Not implemented: WriteLine(Single)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(String)
       method-id. "WriteLine" is public.
       data division.
       working-storage section.
       01  docRun            type "System.Windows.Documents.Run".
       procedure division using s as string.
           set docRun to new "System.Windows.Documents.Run"(
               string::"Concat"(s, type "System.Environment"::"NewLine"))
           invoke _outputParagraph::"Inlines"::"Add"(docRun)
       end method "WriteLine".

*WriteLine(UInt32)
       method-id. "WriteLine" is public.
       procedure division using i as type "System.UInt32".
           invoke self::"Write"("Not implemented: WriteLine(UInt32)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(UInt64)
       method-id. "WriteLine" is public.
       procedure division using i as type "System.UInt64".
           invoke self::"Write"("Not implemented: WriteLine(UInt64)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(String, Object)
       method-id. "WriteLine" is public.
       procedure division using s as type "System.String", o as type "System.Object".
           invoke self::"Write"("Not implemented: WriteLine(String, Object)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(String, Object[])
       method-id. "WriteLine" is public.
       procedure division using s as type "System.String", arr as ArrayOfObject.
           invoke self::"Write"("Not implemented: WriteLine(String, Object[])")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(Char[], Int32, Int32)
       method-id. "WriteLine" is public.
       linkage section.
       01  buffer    object reference ArrayOfChar.
       01  intIndex  binary-long.
       01  intCount  binary-long.
       procedure division using buffer, intIndex, intCount.
           invoke self::"Write"(string::"New"(buffer, intIndex, intCount))
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(String, Object, Object)
       method-id. "WriteLine" is public.
       procedure division using s as type "System.String", o1 as type "System.Object", o2 as type "System.Object".
           invoke self::"Write"("Not implemented: WriteLine(String, Object, Object)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

*WriteLine(String, Object, Object, Object)
       method-id. "WriteLine" is public.
       procedure division using s as type "System.String", o1 as type "System.Object", o2 as type "System.Object", o3 as type "System.Object".
           invoke self::"Write"("Not implemented: WriteLine(String, Object, Object, Object)")
           invoke self::"WriteLine"(string::"Empty")
       end method "WriteLine".

       end object.
       end class ParagraphWriter.
       
*--------------------------------------------------------------------------------------------------

*      Here's an example of a delegate which takes a parameter, and has no
*      return type. This is equivalent to type Action<T> in .NET framework 3.5.

*      Note that the delegate-id paragraph is a non-standard language extension.             
       
       delegate-id. VoidAction as "Barbarian.VoidAction".
       procedure division using by value docRun as type "System.Windows.Documents.Run".

*          The method is just a prototype, and should contain no implementation.

       end delegate VoidAction.
